package com.runfast.waimai.web.controller.Driver_controller;

import com.runfast.paotui.dao.model.RunfastShopper;
import com.runfast.paotui.service.RunfastShopperService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/shopper/all/*")
public class ShopperAllController {

    @Resource
    RunfastShopperService shopperService;
    //按照 起始时间查询 代理商的 骑手信息
    @PostMapping("driver")
    public @ResponseBody ModelMap driver(
            Integer agereid ,String name ,String createtime1, String createtime2
    ) throws ParseException {
        ModelMap model=new ModelMap();
        String name1="%"+name+"%";
        DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date time1=format.parse(createtime1.toString());
        Date time2=format.parse(createtime2.toString());
        List<RunfastShopper> runfastShopperList =shopperService.findNameAndAgerenAndTime(1,name1,time1,time2);
        if(runfastShopperList==null){
                model.put("msg","没有符合条件的统计");
        }model.put("list",runfastShopperList);
        return  model;
    }
}
